﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Security.Cryptography;
using System.Text;

/// <summary>
/// Summary description for RoomService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class RoomService : System.Web.Services.WebService {

    public RoomService () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    private Database db = DatabaseFactory.CreateDatabase("cns");
    #region
    [WebMethod]
    public DataTable GetRoomList(int RoomNo)
    {
        DataTable RoomList = new DataTable();
        RoomList.TableName = "RoomList";
        var roomlist = db.ExecuteDataSet("sp_RoomList", RoomNo);
        if (roomlist.Tables.Count >= 0)
            RoomList = roomlist.Tables[0];
        return RoomList;
    }

    [WebMethod]
    public DataTable GetRoomHouseKeeping()
    {
        DataTable housekeeping = new DataTable();
        housekeeping.TableName = "RoomHouseKeeping";
        var roomhousekeepinglist = db.ExecuteDataSet(CommandType.StoredProcedure, "sp_RoomHouseKeeping");
        if (roomhousekeepinglist.Tables.Count >= 0)
            housekeeping = roomhousekeepinglist.Tables[0];
        return housekeeping;
    }

    [WebMethod]
    public DataTable GetRoomTypeID()
    {
        DataTable roomtypeid = new DataTable();
        roomtypeid.TableName = "RoomHouseKeeping";
        var roomhousekeepinglist = db.ExecuteDataSet(CommandType.StoredProcedure, "sp_RoomHouseKeeping");
        if (roomhousekeepinglist.Tables.Count >= 0)
            roomtypeid = roomhousekeepinglist.Tables[0];
        return roomtypeid;
    }

    [WebMethod]
    public DataTable GetRoomStatus()
    {
        DataTable roomstatus = new DataTable();
        roomstatus.TableName = "RoomStatus";
        var roomstatuslist = db.ExecuteDataSet(CommandType.StoredProcedure, "sp_RoomStatus");
        if (roomstatuslist.Tables.Count >= 0)
            roomstatus = roomstatuslist.Tables[0];
        return roomstatus;
    }
    #endregion


    #region Excute Methods
    [WebMethod]
    public int UpdateRoom(int RoomNo, string HouseKeepingStatus, string RoomStatus)
    {
        int result = db.ExecuteNonQuery("sp_RoomUpdate", RoomNo, HouseKeepingStatus, RoomStatus);
        return result;
    }

    [WebMethod]
    public int AddRoom(int RoomNo, string RoomTypeID, int NumberOfPerson, string HouseKeepingStatus, string RoomStatus, float Rate)
    {
        int result = db.ExecuteNonQuery("sp_RoomAdd", RoomNo, RoomTypeID, NumberOfPerson, HouseKeepingStatus, RoomStatus, Rate);
        return result;
    }

    [WebMethod]
    public int DeleteRoom(int RoomNo)
    {
        int result = db.ExecuteNonQuery("sp_RoomDelete", RoomNo);
        return result;
    }
    #endregion
}
